[Reflection.Assembly]::LoadWithPartialName("System.Security") | Out-Null
function Encrypt-String($String, [switch]$arrayOutput)
{
	$rij = new-Object System.Security.Cryptography.RijndaelManaged
	$pass = [Text.Encoding]::UTF8.GetBytes($passPhrase)
	$salt = [Text.Encoding]::UTF8.GetBytes($saltValue)
	$rij.Key = (new-Object Security.Cryptography.PasswordDeriveBytes $pass, $salt, "SHA1", 5).GetBytes(32) #256/8
	$rij.IV = (new-Object Security.Cryptography.SHA1Managed).ComputeHash( [Text.Encoding]::UTF8.GetBytes($initVector) )[0..15]
	$encryptor = $rij.CreateEncryptor()
	$memorystream = new-Object IO.MemoryStream
	$cryptostream = new-Object Security.Cryptography.CryptoStream $memorystream,$encryptor,"Write"
	$streamwriter = new-Object IO.StreamWriter $cryptostream
	$streamwriter.Write($String)
	$streamwriter.Close()
	$cryptostream.Close()
	$memorystream.Close()
	$rij.Clear()
	[byte[]]$result = $memorystream.ToArray()
	return [Convert]::ToBase64String($result)
}
if(Test-Path -Path ".\EncryptionConfig.xml")
{
	[xml]$global:encryptionconfig = Get-Content -Path ".\EncryptionConfig.xml"
	$global:passPhrase=$encryptionconfig.configuration.passPhrase.value
	$global:saltValue=$encryptionconfig.configuration.saltValue.value
	$global:initVector=$encryptionconfig.configuration.initVector.value
	$string = read-host "Please Enter Plain Text that has to be encrypted ::"
	$encrypted = Encrypt-String $string
	write-host "Encrypted Password is: $encrypted"
}
else
{
	write-host "EncryptionConfig.xml is missing"
	return "Failure"
}
